/*
 * calendario.cpp
 *
 *  Created on: 19 de Out de 2011
 *      Author: pedrocouto
 */

#include "calendario.h"

Data::Data(int a, int m, int d) {
	//ANO
	if (a > 0)
		ano = a;
	else
		throw DataInvalida<string>("Ano");

	//MES
	if (m >= 1 && m <= 12)
		mes = m;
	else throw DataInvalida<string>("Mes");

	//DIA
	if(d>0){
		if(mes==2){
			if(d<=28)
				dia=d;
			else
				throw DataInvalida<string>("Dia");
		}
		else if((mes%2>0 && mes<=7) || (mes>7 && mes%2==0)){
			if(d<=31)
				dia=d;
			else
				throw DataInvalida<string>("Dia");
		}
		else if((mes%2==0 && mes<=7) || (mes%2>0 && mes>7)){
			if(d<=30)
				dia=d;
			else
				throw DataInvalida<string>("Dia");
		}
		else{
			throw DataInvalida<string>("Dia");
		}
	}
}

std::ostream & Data::operator <<(std::ostream & o){
	o << dia << '/' << mes << '/' << ano;
	return o;
}
/*
void Calendario::removeDataEspetaculo(Data_Espetaculo de) {
	for (unsigned int i = 0; i <= calendario.size(); i++) {
		if (de.&&)
	}
}*/

